import { defineConfig, globalIgnores } from 'eslint/config'
import globals from 'globals'
import js from '@eslint/js'
import pluginVue from 'eslint-plugin-vue'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import stylisticPlugin from '@stylistic/eslint-plugin'

export default defineConfig([
  {
    name: 'app/files-to-lint',
    files: ['**/*.{js,mjs,jsx,vue}'],
  },

  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),

  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.node, // 如果需要 Node.js 全局变量
      },
      parserOptions: {
        ecmaVersion: 'latest',
        sourceType: 'module',
      },
    },
  },

  js.configs.recommended,
  ...pluginVue.configs['flat/essential'],
  skipFormatting,

  // 添加你的自定义规则
  {
    plugins: {
      '@stylistic': stylisticPlugin,
    },
    rules: {
      // Vue 规则
      'vue/multi-word-component-names': 'off',

      // 代码风格规则
      '@stylistic/indent': ['error', 2],
      '@stylistic/quotes': ['error', 'single'],
      '@stylistic/semi': ['error', 'never'],
      '@stylistic/max-len': ['error', { code: 80 }],
      '@stylistic/comma-dangle': ['error', 'never'], 

      // 保留的 Vue 相关规则
      'vue/no-setup-props-destructure': 'off',

      // 其他自定义规则
      'no-undef': 'error',
    },
  },
])
